package BusinessRegister;
import java.awt.event.ActionListener;
	 
import javax.swing.*;
	 
public class CalculatorView extends JFrame{
	 
	    private JTextField firstNumber  = new JTextField(10);
	    private JLabel additionLabel = new JLabel("+");
	    private JTextField secondNumber = new JTextField(10);
	    private JButton calculateButton = new JButton("Calculate");
	    private JTextField calcSolution = new JTextField(10);
	     
	    CalculatorView(){
	         
	        // Sets up the view and adds the components
	         
	        JPanel calcPanel = new JPanel();
	         
	        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
	        this.setSize(600, 200);
               // this.setSize(WIDTH, WIDTH);
	        
                firstNumber.setAlignmentX(100);
                firstNumber.setAlignmentY(300);
                
	        calcPanel.add(firstNumber);
	        calcPanel.add(additionLabel);
	        calcPanel.add(secondNumber);
	        calcPanel.add(calculateButton);
	        calcPanel.add(calcSolution);
	        
	        this.add(calcPanel);
	        
               // firstNumber.setHorizontalAlignment(300);
                
	        // End of setting up the components --------
	         
	    }
            
            public static void main(String[] args)
            {
                CalculatorView theView = new CalculatorView();
                theView.setVisible(true);
            }
	     
	    public int getFirstNumber(){
	         
	        return Integer.parseInt(firstNumber.getText());
	         
	    }
	     
	    public int getSecondNumber(){
	         
	        return Integer.parseInt(secondNumber.getText());
	         
	    }
	     
	    public int getCalcSolution(){
	         
	        return Integer.parseInt(calcSolution.getText());
	         
	    }
	     
	    public void setCalcSolution(int solution){
	         
	        calcSolution.setText(Integer.toString(solution));
	         
	    }
	     
	    // If the calculateButton is clicked execute a method
	    // in the Controller named actionPerformed
	     
	    void addCalculateListener(ActionListener listenForCalcButton){
	         
	        calculateButton.addActionListener(listenForCalcButton);
	         
	    }
	     
	    // Open a popup that contains the error message passed
	     
	    void displayErrorMessage(String errorMessage){
	         
	        JOptionPane.showMessageDialog(this, errorMessage);
	         
	    }
	     
	}
//- See more at: http://www.newthinktank.com/2013/02/mvc-java-tutorial/#sthash.lc72vdfd.dpuf